﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

namespace Galaxy.AutoCAD.Editors
{
    public static class InputTool
    {
        #region 输入角度（定义为editor的括展函数）
        public static double InputAngle(this Editor ed, string message)
        {
            PromptDoubleResult pdr = ed.GetAngle(message);
            double result = 0.0;
            if (pdr.Status == PromptStatus.OK)
            {
                result = pdr.Value;
            }
            else
            {
                result = 0.0;
            }
            return result;
        }
        #endregion
        #region 输入点（定义为editor的括展函数）
        public static Point3d InputPoint(this Editor ed, string message)
        {
            PromptPointResult ppr = ed.GetPoint(message);
            if (ppr.Status == PromptStatus.OK)
            {
                return (Point3d)ppr.Value;
            }
            else
            {
                return new Point3d();
            }
        }
        #endregion
        #region 输入字符串（定义为editor的括展函数）
        public static string InputString(this Editor ed, string message)
        {
            PromptResult pr = ed.GetString(message);
            string result = "";
            if (pr.Status == PromptStatus.OK)
            {
                result = pr.StringResult;
            }
            return result;
        }
        #endregion
        #region 输入double值（定义为editor的括展函数）
        public static double InputDouble(this Editor ed, string message)
        {
            PromptDoubleResult pdr = ed.GetDouble(message);
            double result = 0.0;
            if (pdr.Status == PromptStatus.OK)
            {
                result = pdr.Value;
            }
            return result;
        }
        #endregion
        #region 输入int值（定义为editor的括展函数）
        public static int InputInteger(this Editor ed, string message)
        {
            PromptIntegerResult pir = ed.GetInteger(message);
            int result = 0;
            if (pir.Status == PromptStatus.OK)
            {
                result = pir.Value;
            }
            return result;
        }
        #endregion
        #region 输入关键字（定义为editor的括展函数）
        public static string InputKeyword(this Editor ed,string message, string[] keywords)
        {
            PromptKeywordOptions pko = new PromptKeywordOptions(message);
            for (int i = 0; i < keywords.Length; i++)
            {
                pko.Keywords.Add(keywords[i]);
            }
            pko.Keywords.Default = keywords[0];
            pko.AllowNone = true;
            PromptResult keywords2 = ed.GetKeywords(pko);
            string result = "";
            if (keywords2.Status == PromptStatus.OK)
            {
                result = keywords2.StringResult;
            }
            return result;
        }
        #endregion
    }
}
